package com.suxin.shiro.jwt.exception;

import com.suxin.shiro.jwt.controller.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Tang
 * @classname ExceptionHandler
 * @description [  ]
 * @date 2021/3/28 17:31
 */
@Slf4j
@ControllerAdvice
public class CustomExceptionHandler {

    @ExceptionHandler(value = {CustomExpiredJwtException.class})
    @ResponseBody
    public JsonResult jwtExpired() {
        return new JsonResult(400, "jwtExpired...");
    }

    @ExceptionHandler(value = {RuntimeException.class})
    @ResponseBody
    public JsonResult exceptionHandler(Exception e) {
        return new JsonResult(400, e.getMessage());
    }

}